﻿@ModelType FiledWikiPageModel
@Code
    Dim Versions = WikiModel.Instance.GetPageVersions(Model.Title)
    Versions.Reverse()
End Code

<script type="text/javascript">

    function AllowTwo() {
        var CheckedBoxes = $("input:checkbox[name^='versions']:checked");
        var UnCheckedBoxes = $("input:checkbox[name^='versions']:not(:checked)");

        $("tr:has(input:checkbox[name^='versions']:checked)").addClass("active");
        $("tr:has(input:checkbox[name^='versions']:not(:checked))").removeClass("active");

        UnCheckedBoxes.attr("disabled", (CheckedBoxes.length >= 2));

        $("input:submit").attr("disabled", CheckedBoxes.length != 2);
    }

</script>

<h1>היסטורית גירסאות של הערך '@Model.Title'</h1>

<ul class="action-menu">
    <li>@Html.ActionLink("דף", "FetchExact", New With {.page = Model.Title})</li>
    <li>@Html.ActionLink("עריכה", "Edit", New With {.page = Model.Title})</li>
    <li>@Html.ActionLink("שינוי שם", "Rename", New With {.page = Model.Title})</li>
    <li>@Html.ActionLink("מחיקה", "Delete", New With {.page = Model.Title})</li>
</ul>

<div class="container">
    @Using Html.BeginForm("DoCompareVersions", "Wiki", FormMethod.Get, New With {.name = "CompareForm"})
        @<table class="table">
             <thead>
                 <tr>
                     <th></th>
                     <th>מס'</th>
                     <th>תאריך</th>
                     <th>עורך</th>
                     <th>הערות</th>
                 </tr>
             </thead>
    <tbody>
            @For Each Version In Versions
                @<tr>
                    <td>@Html.CheckBox(String.Format("versions[{0}]", Version.GetVersionCode()), False, New With {.onClick = "AllowTwo()"})</td>
                    <td>@Version.VersionNumber</td>
                    <td>
                        @If Version.IsArchivedVersion Then
                            @Html.ActionLink(Version.DateModeified.ToString(), "FetchVersion", New With {.page = Version.Title, .version = Version.GetVersionCode()})
                        Else
                            @Html.ActionLink(Version.DateModeified.ToString() & " - גרסה נוכחית", "FetchExact", New With {.page = Version.Title})
                        End If
                    </td>
                    <td>@Version.LastAuthor</td>
                    <td>@Version.LastChangeNotes</td>
                </tr>
            Next
            </tbody>
        </table>
        @Html.Hidden("page", Model.Title)
        @<input type="submit" value="השוואת גרסות שנבחרו" disabled="disabled" />
    End Using
</div>
